import Page
from Page import Motorcade
from Base.Base import Base
from selenium.webdriver.common.by import By


class MotorcadeMapPage(Base):
    """
    地图页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.map_home_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.map_back_btn = (By.XPATH, Motorcade.RESOURCE_ID.format('ivBack'))

        # 放大按钮
        self.map_amplification_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("map_increase"))

        # 缩小按钮
        self.map_shrink_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("map_decrease"))

        # 定位图标
        self.map_positioning_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("btn_location"))

        # 语音文案
        self.map_input_voice_tip_text = (By.XPATH, Motorcade.RESOURCE_ID.format("satrt_rob_tv"))

        # 语音按钮
        self.map_voice_btn = (By.XPATH, Motorcade.car_voice_btn.format(""))

        # 语音输入选中框
        self.map_voice_select_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("click_start_rl"))

        # 人数图标
        self.map_number_people_icon = (By.XPATH, Motorcade.RESOURCE_ID.format("online_percent_iv"))

        # 在线人数文本
        self.map_online_users_text = (By.XPATH, Motorcade.RESOURCE_ID.format("map_online_text"))

        # 在线人数标题
        self.map_online_users_title_text = (By.XPATH, Motorcade.car_online_number.format(""))

        # 在线人数选中框
        self.map_online_user_select_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("online_display_ll"))

        # 语音收音图标
        self.map_radio_icon = (By.XPATH, Motorcade.RESOURCE_ID.format("speak_wave"))

        # 开始说话文案
        self.map_radio_start_tip_text = (By.XPATH, Motorcade.RESOURCE_ID.format("rob_mic_text"))

        # 说话倒计时文案
        self.map_radio_start_countdown_text = (By.XPATH, Motorcade.RESOURCE_ID.format("rob_line_number"))

        # 结束按钮
        self.map_radio_stop_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("cancel_rob_tv"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.map_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.map_back_btn)

    def click_amplification(self):
        """
        点击放大按钮

        :return:None
        """
        self.click_element(self.map_amplification_btn)

    def click_shrink(self):
        """
        点击缩小按钮

        :return:None
        """
        self.click_element(self.map_shrink_btn)

    def click_positioning(self):
        """
        点击定位按钮

        :return:None
        """
        self.click_element(self.map_positioning_btn)

    def get_input_voice_tip(self):
        """
        获取语音文案

        :return:获取元素
        """
        return self.find_element_o(self.map_input_voice_tip_text)

    def click_voice(self, index=1):
        """
        点击语音按钮

        :return:None
        """
        self.map_voice_btn = (By.XPATH, Motorcade.car_voice_btn.format(index))
        self.click_element(self.map_voice_btn)

    def click_voice_select(self):
        """
        点击语音选中框按钮

        :return:None
        """
        self.click_element(self.map_voice_select_btn)

    def get_number_people(self):
        """
        获取人数图标

        :return:获取元素
        """
        return self.find_element_o(self.map_number_people_icon)

    def get_online_users(self):
        """
        获取在线人数

        :return:获取元素
        """
        return self.find_element_o(self.map_online_users_text)

    def get_online_users_title(self, index=2):
        """
        获取在线人数标题

        :return:获取元素
        """
        self.map_online_users_title_text = (By.XPATH, Motorcade.car_online_number.format(index))
        return self.find_element_o(self.map_online_users_title_text)

    def click_online_user_select(self):
        """
        点击人数选中框按钮

        :return:None
        """
        self.click_element(self.map_online_user_select_btn)

    def swipe_motorcade_map(self):
        """
        滑动地图界面

        :return:None
        """
        self.swipe_o(location=(350, 1460, 453, 453), direction='lift')

    def is_display_motorcade_map(self):
        """
        是否进入车队详情页

        :return: bool
        """
        return self.is_display(self.map_input_voice_tip_text)

    def get_radio(self):
        """
        获取收音图标

        :return:获取元素
        """
        return self.find_element_o(self.map_radio_icon)

    def get_radio_start_tip(self):
        """
        获取语音提示文案图标

        :return:获取元素
        """
        return self.find_element_o(self.map_radio_start_tip_text)

    def get_radio_start_countdown(self):
        """
        获取语音倒计时文案

        :return:获取元素
        """
        return self.find_element_o(self.map_radio_start_countdown_text)

    def click_radio_stop(self):
        """
        点击结束按钮

        :return:None
        """
        self.click_element(self.map_radio_stop_btn)

    def is_display_motorcade_stop_voice(self):
        """
        是否进入收听语音详情页

        :return: bool
        """
        return self.is_display(self.map_radio_start_tip_text)


if __name__ == '__main__':
    pass
